/*
 DNN Content Builder - sourceforge.net/projects/dnncb
 Copyright (c) 2004-2008
 by Emerson Lopes (emersonlopes@gmail.com)

 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
 documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
 to permit persons to whom the Software is furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all copies or substantial portions 
 of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 DEALINGS IN THE SOFTWARE.
*/

using System;
using System.Collections;
using System.Data;

namespace DNNContentBuilder 
{
	[Serializable]
	public class TasksInfo 
	{
        
		// Entity member variables for database table epTasks
        
		private Int32 mTaskId;
		private string mTitle;
		private string mDescription;
		private Int32 mWorkflowId;
		private Int32 mTaskOrder;
        
		// Calculated Expression member variables for database table epTasks
        
        
		// Entity properties for database table epTasks
        
		public Int32 TaskId 
		{
			get { return mTaskId; }
			set { mTaskId = value; }
		}
        
        
		public string Title 
		{
			get { return mTitle; }
			set { mTitle = value; }
		}
        
		public string Description 
		{
			get { return mDescription; }
			set { mDescription = value; }
		}
        
		public Int32 WorkflowId 
		{
			get { return mWorkflowId; }
			set { mWorkflowId = value; }
		}
        
        
		public Int32 TaskOrder 
		{
			get { return mTaskOrder; }
			set { mTaskOrder = value; }
		}
	}
    
	public class TasksController : BaseController
	{
		public TasksController() : base() {}
		public TasksController(ConnectionProvider cp) : base(cp) {}
        
		public Int32 Add(TasksInfo TasksInfo) 
		{
			return (Int32) base.GetDataProvider().TasksAdd(TasksInfo.Title, TasksInfo.Description, TasksInfo.WorkflowId, TasksInfo.TaskOrder);
		}
        
		public void Update(TasksInfo TasksInfo) 
		{
			base.GetDataProvider().TasksUpdate(TasksInfo.TaskId, TasksInfo.Description, TasksInfo.Title, TasksInfo.WorkflowId, TasksInfo.TaskOrder);
		}
        
		public void Delete(Int32 taskId) 
		{
			base.GetDataProvider().TasksDelete(taskId);
		}

		public void DeleteWorkflowTasks(Int32 workflowId) 
		{
			base.GetDataProvider().DeleteWorkflowTasks(workflowId);
		}

		public TasksInfo GetItem(Int32 taskId) 
		{
			using (IDataReader idr = base.GetDataProvider().TasksGet(taskId))
			{
				TasksInfo infoObject = (TasksInfo)DotNetNuke.Common.Utilities.CBO.FillObject(idr, typeof(TasksInfo));
				return infoObject;
			} 
		}
		
		// Select query methods for database table epTasks
		public ArrayList GetTasksByWorkflow(Int32 WorkflowId) 
		{
			using (IDataReader idr = base.GetDataProvider().TasksGetTasksByWorkflow(WorkflowId))
			{
				ArrayList infoList = DotNetNuke.Common.Utilities.CBO.FillCollection(idr, typeof(TasksInfo));
				return infoList;
			} 
		}
        
		// Relation methods for database table epTasks
		public ArrayList GetByWorkflow(Int32 workflowId) 
		{
			using (IDataReader idr = base.GetDataProvider().TasksByWorkflow(workflowId))
			{
				ArrayList infoList = DotNetNuke.Common.Utilities.CBO.FillCollection(idr, typeof(TasksInfo));
				return infoList;
			} 
		}
	}
}
